﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.Win32;
using VisualStudioProvider.Templates;

namespace ToolboxInstallerTest
{
    public class VSServiceProvider : Microsoft.VisualStudio.OLE.Interop.IServiceProvider
    {
        public int QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject)
        {
            var servicesRootKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\10.0_Config\Services");
            var packagesRootKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\10.0_Config\Packages");
            var serviceKey = servicesRootKey.OpenSubKey("{" + guidService.ToString() + "}");
            var packageKey = Guid.Parse((string) serviceKey.GetValue(""));

            var package = TemplateProvider.Packages[packageKey];
            
            ppvObject = IntPtr.Zero;
            return 1;
        }
    }
}
